using System.Reactive.Concurrency;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using KinonekoSoftware.Extensions.Ioc;
using KinonekoSoftware.Foundation.Languages;
using KinonekoSoftware.Foundation.Styles;
using KinonekoSoftware.Foundation.UI;
using KinonekoSoftware.Foundation.UI.Core;
using KinonekoSoftware.Foundation.UI.ViewModels;
using KinonekoSoftware.Platform.Android;
using KinonekoSoftware.Platform.Core;
using KinonekoSoftware.Platform.Linux;
using KinonekoSoftware.Studio.ViewModels;

using KinonekoSoftware.UI;
using Application = Avalonia.Application;

namespace KinonekoSoftware.Studio
{
    public partial class App : LinuxApplication
    {

        public App()
        {
            Xplat.InstallFromRegisters(typeof(App).Assembly);
        }

        public override void Initialize()
        {
            AvaloniaXamlLoader.Load(this);
        }

        protected override ShellCore CreateShell() => new AppViewModel();

        protected override ThemeSystem InstallTheming(ForestSetting setting)
        {
            return new DarkThemeSystem();
        }

        protected sealed override ApplicationInformation GetApplicationFolderInformation() => Platform.CreateApplicationInformation();
        protected sealed override ForestSetting GetOrCreateSetting(ApplicationInformation ai) => Platform.GetOrCreateSetting(ai);


        protected override void InstallServices()
        {
            //
            //
            //
            //
            // LanguageManager.AddProvider(new StudioLanguageProvider());

            //
            //
            Platform.Init();

            //
            //
            base.InstallServices();
        }

        protected override Window CreateMainView() => new MainWindow();

        protected override void InstallViewAndViewModels()
        {
            var list = new List<MVVMAssociation>(32);
            var impl = new Generators.KinonekoViewAssociationGeneratorGenerated.NClass();
            impl.Register(list);


            foreach (var association in list)
            {
                Xplat.InstallView(association);
            }
        }
    }
}